package POJO;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "USER")
public class User {
	
	@Id
	@Column(name = "User_Name", unique = true, nullable = false, length = 45)
	private String userName;
	
	@Column(name = "Pass_Word", nullable = false, length = 50)
	private String passWord;
	
	@Column(name = "Enable")
	private boolean enable;
	
	@Column(name = "Date_Create")
	private Date dateCreated;
	
	@Column(name = "Last_Visit")
	private Date lastVisit;
	
	@OneToMany(fetch = FetchType.EAGER, mappedBy = "user")
	private Set<UserRole> userRoles = new HashSet<UserRole>(0);

	public User() {
		super();
	}

	public User(String userName, String passWord) {
		super();
		this.userName = userName;
		this.passWord = passWord;
		this.enable = true;
		this.dateCreated = new Date();
	}

	public User(String userName, String passWord, boolean enable) {
		super();
		this.userName = userName;
		this.passWord = passWord;
		this.enable = enable;
		this.dateCreated = new Date();
	}

	public User(String userName, String passWord, boolean enable,
			Set<UserRole> userRoles) {
		super();
		this.userName = userName;
		this.passWord = passWord;
		this.enable = enable;
		this.dateCreated = new Date();
		this.userRoles = userRoles;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassWord() {
		return passWord;
	}

	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getLastVisit() {
		return lastVisit;
	}

	public void setLastVisit(Date lastVisit) {
		this.lastVisit = lastVisit;
	}

	public Set<UserRole> getUserRoles() {
		return userRoles;
	}

	public void setUserRoles(Set<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

}
